﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication1.Servidor1;

namespace WebApplication1
{
    public partial class CrearSocioNegocio : System.Web.UI.Page
    {
        Service1 servidor;
        protected void Page_Load(object sender, EventArgs e)
        {
            servidor = (Service1)Session["Server"];
            if (!Page.IsPostBack)
            {
                if (Session["Server"] != null)
                {
                    List<string> listOfNames = servidor.Obtener_Cuentas(false, Session["NombreEmpresaUsuario"].ToString()).ToList();
                    for (int i = 0; i < listOfNames.Count(); i++)
                        listOfNames[i] = listOfNames[i].Split(';')[0] + ";" + listOfNames[i].Split(';')[1];
                    DropDownList1.DataSource = listOfNames;
                    DropDownList1.DataBind();
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            String nombre = TextBox1.Text;
            String email = TextBox3.Text;
            String cuentaBco = TextBox4.Text;
            float max_credito = Convert.ToSingle(TextBox2.Text);
            int tipo = RadioButtonList1.SelectedIndex;
            String codigo_cuenta = DropDownList1.SelectedValue.ToString().Split(';')[0];
            servidor.Crear_Socio_Negocio(nombre, email, max_credito, tipo, codigo_cuenta, cuentaBco, Session["NombreEmpresaUsuario"].ToString());
            Response.Redirect("VerSaldos.aspx");
        }
    }
}